/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ProgramCreditsWindow.java
 *
 * Created on Aug 3, 2010, 7:43:21 PM
 */

package MainProgram.UI;

import MainProgram.ProgramLaunchers.ProgramLauncher;
import java.awt.Point;
import org.jdesktop.application.Action;
import org.jdesktop.application.Task;

/**
 *
 * @author Stephen
 */
public class ProgramCreditsWindow extends javax.swing.JDialog
{

    /** Creates new form ProgramCreditsWindow */
    public ProgramCreditsWindow(ProgramAboutBox box)
    {
        initComponents();
        setModalityType(ModalityType.APPLICATION_MODAL);
        setIconImage(ProgramLauncher.getProgramIcon(this));

        m_parent = box;
    }

    ProgramAboutBox m_parent = null;

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        v_instructionsScrollPane = new javax.swing.JScrollPane();
        v_creditsTextBox = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(ProgramCreditsWindow.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                WindowShown(evt);
            }
        });

        v_instructionsScrollPane.setBorder(null);
        v_instructionsScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        v_instructionsScrollPane.setName("v_instructionsScrollPane"); // NOI18N

        v_creditsTextBox.setBackground(resourceMap.getColor("v_creditsTextBox.background")); // NOI18N
        v_creditsTextBox.setColumns(20);
        v_creditsTextBox.setEditable(false);
        v_creditsTextBox.setFont(resourceMap.getFont("v_creditsTextBox.font")); // NOI18N
        v_creditsTextBox.setLineWrap(true);
        v_creditsTextBox.setRows(4);
        v_creditsTextBox.setText(resourceMap.getString("v_creditsTextBox.text")); // NOI18N
        v_creditsTextBox.setWrapStyleWord(true);
        v_creditsTextBox.setBorder(null);
        v_creditsTextBox.setFocusable(false);
        v_creditsTextBox.setName("v_creditsTextBox"); // NOI18N
        v_instructionsScrollPane.setViewportView(v_creditsTextBox);

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new java.awt.GridBagLayout());

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(ProgramCreditsWindow.class, this);
        jButton1.setAction(actionMap.get("CloseWindow")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.ipadx = 50;
        gridBagConstraints.ipady = 10;
        jPanel1.add(jButton1, gridBagConstraints);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(v_instructionsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(v_instructionsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-536)/2, (screenSize.height-368)/2, 536, 368);
    }// </editor-fold>//GEN-END:initComponents

    private void WindowShown(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_WindowShown
    {//GEN-HEADEREND:event_WindowShown
        getScrollTask().execute();
    }//GEN-LAST:event_WindowShown
    public Task getScrollTask()
    {
        return new ScrollTask(org.jdesktop.application.Application.getInstance());
    }
    private class ScrollTask extends org.jdesktop.application.Task<Object, Void> {
        ScrollTask(org.jdesktop.application.Application app) {
            // Runs on the EDT.  Copy GUI state that
            // doInBackground() depends on from parameters
            // to AsdfsafTask fields, here.
            super(app);
        }
        @Override
        protected Object doInBackground()
        {
            return null;
        }
        @Override protected void succeeded(Object result)
        {
            v_instructionsScrollPane.getViewport().setViewPosition(new Point(0,0));
        }
    }    @Action
    public void CloseWindow()
    {        
        this.dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextArea v_creditsTextBox;
    private javax.swing.JScrollPane v_instructionsScrollPane;
    // End of variables declaration//GEN-END:variables

}
